#!/bin/sh
#参数1 应用程序名称，如foxit-webreader-web
#参数2 保存包的绝对目录，必须以/s3开头，如：/s3/webreader/webapp/
#参数3 包的版本号,格式为：svn版本_war包版本 （如：24569_V1.0）
#参数4 Tomcat 机器IPS,以逗号分隔
#参数5 jar包，远程服务器存放目录，如/usr/share/tomcat/latest/temp

if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]
then
	echo "Parameters Fail....."
	exit 1;
fi

packageVersionArray=(`echo ${3//_/ }`)
DEPLOY_WAR_NAME=$1
DEPLOY_WAR_DIR="$2/${packageVersionArray[1]}/${packageVersionArray[0]}/"
DEPLOY_WAR_VERSION=${packageVersionArray[1]}
DEPLOY_TOMCAT_IP=$4
REMOTE_WAR_PATH=$5

echo "=========begin transfer parameter========="
echo $DEPLOY_TOMCAT_IP
echo $DEPLOY_WAR_NAME
echo $DEPLOY_WAR_VERSION
echo "=========end transfer parameter========="

. /etc/puppet/tool/puppetFun.sh

SHELL_FILENAME="${JOB_NAME}_deployJar.sh"
cp ${WORKSPACE}/convertranslate-task/deployJar.sh  /etc/puppet/files/${SHELL_FILENAME}

Puppet_Run_Whole_Transfer "${DEPLOY_TOMCAT_IP}" "${SHELL_FILENAME}" "" "${SHELL_FILENAME}" "${DEPLOY_WAR_NAME}" "${DEPLOY_WAR_VERSION}" "${DEPLOY_WAR_DIR}" "${REMOTE_WAR_PATH}"
exit $?